package org.rambadger.query;

import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment;
import org.rambadger.query.resource.PingResource;

/**
 * Query services
 *
 * @author Chris Wash <a href="mailto:chris.wash@gmail.com">chris.wash@gmail.com</a>
 */
public class QueryServices extends Service<QueryConfiguration> {

    @Override
    public void initialize(Bootstrap<QueryConfiguration> queryConfigurationBootstrap) {
        queryConfigurationBootstrap.setName("queryServices");
    }

    @Override
    public void run(QueryConfiguration queryConfiguration, Environment environment) throws Exception {
        final String replyText = queryConfiguration.getReplyText();
        // add Query resource below
        environment.addResource(new PingResource(replyText));
    }

}
